//
//  ST_DailyMomentSignView.swift
//  btvideo
//
//  Created by mac on 2020/7/21.
//  Copyright © 2020 JarvanZhang. All rights reserved.
//

import UIKit

class ST_DailyMomentSignView: UIControl {
    
    static let height = 24.cgFloat
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.backgroundColor = UIColor.init(hex: 0xFEF8E6)
        
        self.cornerRadius = 12
        self.borderWidth = 1
        self.borderColor = UIColor.init(hex: 0xFEC207)
        
        self.addSubview(icon_image_view)
        icon_image_view.snp.makeConstraints { (make) in
            make.width.height.equalTo(18)
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(6)
        }
//        icon_image_view.backgroundColor = .random
        
        self.addSubview(titleLabel)
        titleLabel.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(25)
            make.right.equalToSuperview().offset(-6)
            make.centerY.equalToSuperview()
        }
        
//        titleLabel.backgroundColor = .random
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    

    fileprivate lazy var icon_image_view:UIImageView = {
         let control = UIImageView()
          control.contentMode = .scaleAspectFill
        control.clipsToBounds = true
          return control
      }()

    
    fileprivate lazy var titleLabel:UILabel = {
        let control = UILabel.init()
        control.text = ""
        control.textColor = UIColor.init(hexString: "#FEC207")
        control.font = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.medium)
        return control
    }()
    
    func bind(text:String,url:String)  {
        
        icon_image_view.pin_setImage(from: url.url, placeholderImage: ST_SwiftConst.shared.fetch_random_place_holder_image())
        
        titleLabel.text = "#" + text
    }
    
}
